home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / misc / unix / unix_boot.lha / src / copyit.s < prev    next >
Encoding:
Text File  |  1991-12-09  |  1.9 KB  |  71 lines

  1. | Copyright (C) 1991, Commodore Business Machines, Inc.
  2. |
  3. | Copyit must be called in supervisor mode with a2 pointing
  4. | to copyinfo struct (this is handled by Supervisor.s).
  5. | This code actually gets memcpy()'d into chip ram and executed there.
  6.  
  7.     .set    ABSEXECBASE,4
  8.  
  9. | struct copyinfo:
  10.  
  11.     .set    ci_loadbuf,0
  12.     .set    ci_vaddr,  4
  13.     .set    ci_size,   8
  14.     .set    ci_entry, 12
  15.     .set    ci_d0,    16
  16.     .set    ci_d1,    20
  17.  
  18.  
  19.     .text
  20.     .globl    _copyit
  21.  
  22. _copyit:
  23.     movew    #0x2700,sr
  24.  
  25.     lea    pc@(zero-.+2),a0
  26.     pmove    a0@,tc            | Turn off MMU
  27.     lea    pc@(nullrp-.+2),a0
  28.     pmove    a0@,crp            | Turn off MMU some more
  29.     pmove    a0@,srp            | Really, really, turn off MMU
  30.  
  31. | Turn off 68030 TT registers
  32.  
  33.     btst    #2,(ABSEXECBASE)@(0x129) | AFB_68030,SysBase->AttnFlags
  34.     beq    nott            | Skip TT registers if not 68030
  35.     lea    pc@(zero-.+2),a0
  36.     .word 0xf010,0x0800        | pmove a0@,tt0 (gas only knows about 68851 ops..)
  37.     .word 0xf010,0x0c00        | pmove a0@,tt1 (gas only knows about 68851 ops..)
  38.  
  39. nott:
  40.     movel    a2@(ci_loadbuf),a0    | a0 = Pointer to text+data buffer
  41.     movel    a2@(ci_vaddr),a1    | a1 = Virtual addr to move buffer to
  42.     movel    a2@(ci_size),d0        | d0 = Size of text+data
  43.     cmpl    a0,a1            | See which direction to shift kernel
  44.     bcc    copydown        |  in memory, up or down (a0-a1)
  45.     addl    d0,a0            | Copy up from tail of buffer
  46.     addl    d0,a1            |  to tail of kernel memory
  47.  
  48. copyup:                    | Shuffle kernel up in memory
  49.     moveb    a0@-,a1@-        |  moving bytes from buffer to dest
  50.     subl    #1,d0            |  one byte at a time from tail
  51.     bcc    copyup            |  until all bytes are moved
  52.     bra    copydone
  53.  
  54. copydown:                | Shuffle kernel down in memory
  55.     moveb    a0@+,a1@+        |  moving bytes from buffer to dest
  56.     subl    #1,d0            |  one byte at a time from head
  57.     bcc    copydown        |  until all bytes are moved
  58.  
  59. copydone:
  60.     movel    a2@(ci_entry),a0    | Get kernel entry point
  61.     movel    a2@(ci_d0),d0        |  and first argument to kernel
  62.     movel    a2@(ci_d1),d1        |  and second argument to kernel
  63.     jmp    a0@            |  and go for it
  64.  
  65. # A do-nothing MMU root pointer (includes the following long as well)
  66.  
  67. nullrp:    .long    0x7fff0001
  68. zero:    .long    0
  69.  
  70.  
  71.